/**
 * @description =>zy
 */
import Cookies from 'js-cookie'
import Config from '@/config'

import storage from './storage'

const TokenKey = Config.TokenKey

/* Cookies save */
export function getToken() {
  return Cookies.get(TokenKey)
}

export function setToken(token, rememberMe) {
  if (rememberMe) {
    return Cookies.set(TokenKey, token, { expires: Config.tokenCookieExpires })
  } else return Cookies.set(TokenKey, token)
}

export function removeToken() {
  return Cookies.remove(TokenKey)
}
/* localStorage save */
// export function getToken() {
//   return storage.get(TokenKey)
// }

// export function setToken(token, rememberMe) {
//   if (rememberMe) {
//     return Cookies.set(TokenKey, token, { expires: Config.tokenCookieExpires })
//   } else return storage.set(TokenKey, token)
// }

// export function removeToken() {
//   return storage.remove(TokenKey)
// }
export function getAccount() {
  return storage.get('addAccount')
}

export function setAccount(userId) {
  return storage.set('addAccount', userId)
}

export function removeAccount() {
  return storage.remove('addAccount')
}
